package com.dream.service.recommender.toolkits.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class ConfigUtil {

    static Properties properties;

    static {
    	InputStream inputStream = null;
        try {
        	 inputStream  = ConfigUtil.class.getClassLoader().getResourceAsStream("config.properties");
        	properties = new Properties();
            properties.load(inputStream);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (inputStream != null) {
                    inputStream.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static String getPro(String key){
    	return getPro(key, "");
    }

    public static String getPro(String key, String def_value){
    	String value = properties.getProperty(key);
    	if(value == null || value.trim().equals("")){
    		value = def_value;
    	}
    	return value;
    }
}
